package com.qinggeng.project.system.factory;

import com.qinggeng.project.system.domain.DistributionPointWxImg;
import com.qinggeng.project.system.domain.vo.DistributionPointImgVO;
import com.qinggeng.project.system.mapper.DistributionPointShopImgMapper;
import com.qinggeng.project.system.mapper.DistributionPointWxImgMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Component
public class DistributionPointImgFactory {

    @Autowired
    private DistributionPointShopImgMapper distributionPointShopImgMapper;


    @Autowired
    private DistributionPointWxImgMapper distributionPointWxImgMapper;


    public   DistributionPointImgVO getDistributionPointImgVO(Long pointId){
        DistributionPointImgVO distributionPointImgVO=new DistributionPointImgVO();

        List<String> shopImgs=distributionPointShopImgMapper.listPointPointId(pointId);
        distributionPointImgVO.setDistributionPointShopImg(shopImgs);
        Example example =new Example(DistributionPointWxImg.class);
        example.createCriteria().andEqualTo("pointId",pointId);
        DistributionPointWxImg wxImg=distributionPointWxImgMapper.selectOneByExample(example);
        if (wxImg==null){
            wxImg=new DistributionPointWxImg();
        }
        distributionPointImgVO.setDistributionPointWxImg(wxImg.getImageUrl());
        return distributionPointImgVO;
    }
}
